<template>
  <div class="comment">
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input placeholder="用户名" />
      </el-form-item>
      <el-form-item>
        <el-select clearable placeholder="订单状态">
          <el-option value="1" label="待支付" />
          <el-option value="2" label="待派单" />
          <el-option value="3" label="待服务" />
          <el-option value="4" label="待确认" />
          <el-option value="5" label="已完成" />
        </el-select>
      </el-form-item>
      <el-form-item label="添加时间">
        <el-date-picker
          type="datetime"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-form-item>
        <el-date-picker
          type="datetime"
          placeholder="选择截止时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>
    <!-- 表格 -->
    <el-table :data="comment">
      <el-table-column type="index" :index="1" label="编号" width="80" />
      <el-table-column prop="user.realname" label="用户名" width="80" />
      <el-table-column prop="order.id" label="订单编号" />
      <el-table-column prop="order.status" label="订单状态" />
      <el-table-column prop="score" label="分数" />
      <el-table-column prop="content" label="内容" />
      <el-table-column prop="commentTime" label="评论时间" />
      <el-table-column prop="orderId" label="订单编号" />
      <el-table-column label="操作" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="shenhe(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格结束 -->
    <!-- 模态框 -->
    <el-dialog title="评论审核" :visible.sync="visible">
      <p>分数：{{this.emp.score}}</p>
      <p>内容：{{this.emp.content}}</p>

      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="submit">审核通过</el-button> -->
        <el-button type="danger" @click="refuse">评论违规</el-button>
      </div>
    </el-dialog>
    <!-- 模态框结束 -->
  </div>
</template>
<script>
import { get } from '@/utils/request'
export default {
  data() {
    return {
      visible: false,
      comment: [],
      emp: []
    }
  },
  created() {
    this.loadComment()
  },
  methods: {
    loadComment() {
      let url = 'http://47.93.12.6:8889/comment/findAllCommentDetail'
      get(url).then(response => {
        this.comment = response.data
      })
    },
    shenhe(row) {
      this.emp = row
      this.visible = true
    },
    // submit() {
    //   let url = "http://47.93.12.6:8889/comment/auditing";
    //   get(url, { id: this.emp.id }).then(response => {
    //     this.$message({ type: "success", message: response.message });
    //     this.loadComment();
    //   });
    //   this.visible = false;
    //   this.loadComment();
    // },
    refuse() {
      let url = 'http://47.93.12.6:8889/comment/refuseauditing'
      get(url, { id: this.emp.id }).then(response => {
        this.$message({ type: 'success', message: response.message })
        this.loadComment()
      })
      this.visible = false
      this.loadComment()
    }
  }
}
</script>